package arithmetique;

/**
 * @author Chen / Yvonnic
 * The Class Interval represent the intervals
 */
public class Interval {

	//min value of a interval
	private double intervalMin;
	
	//max value of a interval
	private double intervalMax;
	
	/**
	 * Constructor by default
	 * @param min := min value of the interval : double
	 * @param max := max value of the interval : double
	 */
	public Interval(double min, double max) {
		this.intervalMin = min;
		this.intervalMax = max;
	}

	/**
	 * @return := max value of a interval : double
	 */
	public double getMax() {
		return intervalMax;
	}

	/**
	 * @return := min value of a interval : double
	 */
	public double getMin() {
		return intervalMin;
	}

	/**
	 * @param i := another interval : Interval
	 * @return := the sun of 2 intervals
	 */
	public Interval plus(Interval i) {		
		this.intervalMin += i.getMin();
		this.intervalMax += i.getMax();
		return this;
	}

	public Interval plusNew(Interval i) {
		return new Interval(this.intervalMin + i.getMin(), this.intervalMax + i.getMax());
	}
	
	public Interval copy(){
		return new Interval(this.intervalMin, this.intervalMax);
	}
}
